home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Apple II / Programming & Utilities / Apple IIgs APW Intro Prog Src / HP.CC / PRINT.CC.txt < prev    next >
Encoding:
Text File  |  1987-07-28  |  2.0 KB  |  89 lines

  1.  
  2. #include <types.h>
  3. #include <memory.h>
  4. #include <quickdraw.h>
  5. #include <window.h>
  6. #include <print.h>
  7. #include <qdaux.h>
  8. #include <font.h>
  9. #include "hp.h"
  10.  
  11. extern int MyID;
  12.  
  13. GrafPortPtr WindowToPrint = NIL;
  14.  
  15. handle PrintRecord = NIL;
  16.  
  17. GrafPortPtr PrintPort;
  18.  
  19. /* Coose Printer Item handler */
  20.  
  21. DoChooserItem()
  22. {
  23.    PrChooser();
  24. }
  25.  
  26. /* Routine to handle page setup item */
  27.  
  28. DoSetUpItem()
  29. {
  30.    if (!(PrintRecord))
  31.      SetUpDefault();
  32.    PrStlDialog(PrintRecord);
  33. }
  34.  
  35. /* routine to create default print record */
  36.  
  37. SetUpDefault()
  38. {
  39.      PrintRecord = NewHandle(140L,MyID,0x8010,0L);
  40.      PrDefault(PrintRecord);
  41. }
  42.  
  43. /* Now the menu item "Print" item */
  44.  
  45. DoPrintItem()
  46. {
  47.    if (WindowToPrint = FrontWindow())          /* is there a window to print? */
  48.      {
  49.        if (!(PrintRecord))
  50.          SetUpDefault();
  51.        if (PrJobDialog(PrintRecord))
  52.          {
  53.            WaitCursor();
  54.            PrintPort = PrOpenDoc(PrintRecord,0L);
  55.            PrOpenPage(PrintPort,0L);
  56.            DrawTopWindow();
  57.            PrClosePage(PrintPort);
  58.            PrCloseDoc(PrintPort);
  59.            PrPicFile(PrintRecord,0L,0L);
  60.            InitCursor();
  61.          }
  62.      }
  63. }
  64.  
  65. DrawTopWindow()
  66. {
  67.  
  68. DataRecHandle TheRefCon = NIL;                 /* we use slightly different */
  69. DataRecPtr auxPtr;                             /* structures for pictures   */
  70.  
  71. FDataRecHandle FontHandle;                     /* and for fonts             */
  72. FDataRecPtr FontPtr;
  73.  
  74.    TheRefCon = (DataRecHandle)GetWRefCon(WindowToPrint);
  75.    HLock(TheRefCon);
  76.    auxPtr = *TheRefCon;
  77.    if (auxPtr -> Flag)                         /* non_zero --> font */
  78.      {
  79.        FontHandle = (FDataRecHandle)GetWRefCon(WindowToPrint);   /* again        */
  80.        HLock(FontHandle);                        /* to pass    */
  81.        FontPtr = *FontHandle;                    /* the right  */
  82.        ShowFont(FontPtr -> FID,FontPtr);         /* stuff      */
  83.        HUnlock(FontHandle);
  84.      }
  85.    else                                        /* Picture Window */
  86.      PaintIt(auxPtr -> PicHand);
  87.    HUnlock(TheRefCon);
  88. }
  89.